﻿/**************************************************************
* 功   能 ：指令窗体
* 创 建 人：ColaShou
* 创建时间：2023-08-04
* 最近修改人：
* 修改  时间：
* 修改  内容:
* ***************************************************************/

namespace ColaWinFormFrameWork
{
    using System;
    using System.Windows.Forms;
    using ColaWinFormFrameWork.UICommon.Dto;

    /// <summary>
    /// FormUnit.
    /// </summary>
    public partial class FormUnit : Form
    {
        private string unitParam = string.Empty; // 传递的参数

        /// <summary>
        /// FormUnit.
        /// </summary>
        /// <param name="param">浏览器的入参.</param>
        public FormUnit(string param)
        {
            this.unitParam = param;
            this.InitializeComponent();
            this.InitOpenUnit(); // 调用初始启动的指令
        }

        /// <summary>
        /// 初次启动程序打开的指令.
        /// </summary>
        public void InitOpenUnit()
        {
            switch (unitParam)
            {
                case "100001":
                    Form1 form1 = new Form1();
                    form1.Show();
                    break;

                case "100002":
                    Form2 form2 = new Form2();
                    form2.Show();
                    break;
            }
        }

        /// <summary>
        /// 接收其他进程传递过来的消息.
        /// </summary>
        /// <param name="message">消息入参.</param>
        protected override void DefWndProc(ref Message message)
        {
            switch ((int)message.LParam)
            {
                case 100001:
                    Form1 form1 = new Form1();
                    form1.Show();
                    break;
                case 100002:
                    Form2 form2 = new Form2();
                    form2.Show();
                    break;
                default:
                    base.DefWndProc(ref message);
                    break;
            }
        }
    }
}
